package HTMLCrators;

import java.io.IOException;
import java.util.Collection;

import Main.Pair;


public class HTMLCreatorFromFileAndPairs extends HTMLCreatorFromFile {

	private Collection<Pair<String,String>> pairs;

	public HTMLCreatorFromFileAndPairs(String fileName,Collection<Pair<String,String>> pairs) throws IOException {
		super(fileName);
		this.pairs=pairs;
	}

	protected String editLine(String line){
		for(Pair<String,String> pair : pairs){
			int index=line.indexOf(pair.getFirst());
			while (index!=-1){
				line=line.substring(0,index)+pair.getSecend()+line.substring(index+pair.getFirst().length());
				index=line.indexOf(pair.getFirst());
			}
		}
		return line;
	}
}
